// Fill out your copyright notice in the Description page of Project Settings.


#include "StateMachine/PlayerState/MoveState.h"

#include "InputActionValue.h"
#include "Core/Character2D.h"
#include "StateMachine/StateMachine.h"
#include "StateMachine/PlayerState/IdleState.h"

void UMoveState::Enter()
{
	Super::Enter();
	UE_LOG(LogTemp, Warning, TEXT("Entering UMoveState::Enter()"));
	Character->PlayAnimation(FName("Move"));
}

void UMoveState::Exit()
{
	Super::Exit();
	UE_LOG(LogTemp, Warning, TEXT("Exiting UMoveState::Exit()"));
}

void UMoveState::Tick(float Delta)
{
	Super::Tick(Delta);
}

void UMoveState::InputSignal(EInputSignal Signal, const FInputActionValue& Value)
{
	Super::InputSignal(Signal, Value);

	if (Signal == EInputSignal::Moving)
	{
		MoveDir = Value.Get<FVector>();
		Character->FlipSprite(MoveDir.Y);
		Character->Movement(MoveDir);
	}
	
	

	if (Signal == EInputSignal::MoveEnd)
	{
		StateMachine->SwitchState(UIdleState::StaticClass());
		return;
	}
}


